home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4076 / 4076.xpi / chrome / addthis.jar / content / main.js < prev    next >
Encoding:
Text File  |  2010-01-06  |  4.2 KB  |  110 lines

  1. /* 
  2.  * +--------------------------------------------------------------------------+
  3.  * | Copyright (c) 2009-10 Add This, LLC                                      |
  4.  * +--------------------------------------------------------------------------+
  5.  * | This program is free software; you can redistribute it and/or modify     |
  6.  * | it under the terms of the GNU General Public License as published by     |
  7.  * | the Free Software Foundation; either version 3 of the License, or        |
  8.  * | (at your option) any later version.                                      |
  9.  * |                                                                          |
  10.  * | This program is distributed in the hope that it will be useful,          |
  11.  * | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
  12.  * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
  13.  * | GNU General Public License for more details.                             |
  14.  * |                                                                          |
  15.  * | You should have received a copy of the GNU General Public License        |
  16.  * | along with this program.  If not, see <http://www.gnu.org/licenses/>.    |
  17.  * +--------------------------------------------------------------------------+
  18.  */
  19.  
  20. AddThis_Util.dbg("main: top");
  21.  
  22.  
  23. window.addEventListener("load", function() { AddThis.init(); }, false);
  24.  
  25.  
  26. var AddThis = {
  27.   
  28.     init: function() {
  29.         AddThis_Util.dbg("main.init: entered");
  30.         
  31.         var firstrun = !AddThis_Util.getBooleanPref("extensions.addthis.init", false),
  32.             upgrade = (AddThis_Util.getStringPref("extensions.addthis.session","")=="");
  33.         
  34.         if (firstrun) {
  35.             AddThis_Util.dbg("main.init: first run");
  36.             AddThis_Util.loadServiceDefaults();
  37.             AddThis_Toolbar.setVisibility(true);
  38.             AddThis_MainButton.setVisibility(false);
  39.             AddThis_Util.setBooleanPref('extensions.addthis.urlbar.disable', true);
  40.             AddThis_UrlBar.setVisibility(false);
  41.             AddThis_ContextMenu.setVisibility(true);
  42.             AddThis_Util.setBooleanPref("extensions.addthis.init", true);
  43.             AddThis_Util.navToUrl(AddThis_Constants.WELCOME_URL);
  44.         } else if (upgrade) {
  45.             AddThis_Util.dbg("main.init: upgrade");
  46.             AddThis_Toolbar.setVisibility(true);
  47.             AddThis_Util.navToUrl(AddThis_Constants.WELCOME_URL);
  48.         }
  49.         
  50.         
  51.         AddThis_UrlBar.init();
  52.         AddThis_Toolbar.init();
  53.         AddThis_Toolbar.resizeDelay();
  54.         
  55.         
  56.         AddThis_Search.init();
  57.         
  58.         
  59.         var contextMenu = document.getElementById("contentAreaContextMenu");
  60.         contextMenu.addEventListener("popupshowing", AddThis_ContextMenu.setVisibility,true);
  61.         var toolsMenu = document.getElementById("menu_ToolsPopup");
  62.         toolsMenu.addEventListener("popupshowing", AddThis_ToolsMenu.setVisibility,true);
  63.         window.addEventListener("resize", AddThis_Toolbar.resizeDelay, true);
  64.         
  65.         AddThis_Util.png();
  66.         if (firstrun || upgrade) {
  67.             window.setTimeout(AddThis.showWelcome,1500);
  68.         }
  69.         AddThis_Util.dbg("main.init: exiting");
  70.       },
  71.     
  72.     showPreferences: function() {
  73.         AddThis_Util.dbg("showPreferences: popping window...");
  74.         var w = window.openDialog('chrome://addthis/content/preferences.xul', 'AddThis Preferences', 'centerscreen,chrome,titlebar,toolbar');
  75.         w.focus();
  76.     },
  77.     
  78.     gotoFeedback: function()
  79.     {
  80.         AddThis_Util.navToUrl(AddThis_Constants.FEEDBACK_URL);
  81.     },
  82.     
  83.     showAbout: function()
  84.     {
  85.         AddThis_Util.dbg("showAbout: popping window...");
  86.         var w = window.openDialog('chrome://addthis/content/about.xul', '', 'centerscreen,chrome,titlebar,toolbar');
  87.         w.focus();
  88.     },
  89.     
  90.     showWelcome: function() {
  91.         AddThis_Util.dbg("showWelcome: popping window...");
  92.         var w = window.openDialog('chrome://addthis/content/welcome.xul', '', 'centerscreen,chrome,titlebar,toolbar,modal');
  93.         w.focus();
  94.     },
  95.     
  96.     gotoAddThis: function()
  97.     {
  98.         AddThis_Util.navToUrl("http://www.addthis.com");
  99.     },
  100.     
  101.     shareAddon: function()
  102.     {
  103.         AddThis_Sharing.invokeService('more',AddThis_Constants.AMO_URL,AddThis_Constants.AMO_TITLE);
  104.     }
  105.     
  106. };
  107.  
  108. AddThis_Util.dbg("main: done");
  109.  
  110.